package main

import (
	"fmt"
	"go_final/mxshop_srvs/inventory_srv/model"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
)

func main() {
	dsn := "root:root@tcp(120.24.67.46:4306)/mxshop_inventory_srv?charset=utf8mb4&parseTime=True&loc=Local"

	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
		Logger: logger.Default.LogMode(logger.Info),
	})

	if err != nil {
		fmt.Println("err", err)
	}

	//_ = db.AutoMigrate(
	//	// &model.Inventory{},
	//	&model.StocksSellDetail{},
	//)

	//orderDetail := model.StocksSellDetail{
	//	OrderSn: "imooc_Felix",
	//	Status:  1,
	//	Detail: []model.GoodsDetail{
	//		{
	//			Goods: 1,
	//			Num:   2,
	//		},
	//		{
	//			Goods: 2,
	//			Num:   3,
	//		},
	//	},
	//}
	//
	//db.Create(&orderDetail)

	var sellDetail model.StocksSellDetail
	db.Where(model.StocksSellDetail{
		OrderSn: "imooc_Felix",
	}).First(&sellDetail)
	fmt.Println("sellDetail ", sellDetail)
}
